import { hasComponent } from 'bitecs';
import { Stored, removeFromInventory } from './inventory';
import { removeMemory, VisualMemory } from './memory';
import { hasPos3, unregisterFromMap } from './pos3';

/**
 * Remove mentions of entity in other places
 *
 * TODO: make modular
 */
export const cleanup = (world, e) => {
  if (hasComponent(world, Stored, e)) {
    removeFromInventory(world, Stored.parent[e], e);
  }
  if (hasComponent(world, VisualMemory, e)) {
    removeMemory(e);
  }
  if (hasPos3(world, e)) {
    unregisterFromMap(world, e);
  }
};
